package main

//import "fmt"
import "io/ioutil"
import "strings"
import "os"

func main() {
	var sourcesFolder string = "minecraft-server"
	var searchString string = os.Args[1]

	println("Searching " + searchString)

	files, error := ioutil.ReadDir("./" + sourcesFolder)

	println("Files: ", len(files))

	if error == nil {
		var loopFileName, currentLine string

		for fileIterator := range files {

			loopFile := files[fileIterator]
			loopFileName = loopFile.Name()

			javaFileText, errorFile := ioutil.ReadFile(sourcesFolder + "/" + loopFileName)

			if errorFile == nil {
				currentLine = string(javaFileText)
				if strings.Contains(currentLine, searchString) {
					println(">>> " + loopFileName)
				}

			}

		}
	} else {
		println("No have files in directory /" + sourcesFolder)
	}
}
